package com.xialuo.study.std;

import org.bsc.langgraph4j.serializer.Serializer;
import org.springframework.ai.chat.messages.AssistantMessage;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;


public class ToolCallSerializer implements Serializer<AssistantMessage.ToolCall> {

    @Override
    public void write(AssistantMessage.ToolCall object, ObjectOutput out) throws IOException {
        out.writeUTF(object.id());
        out.writeUTF(object.type());
        out.writeUTF(object.name());
        out.writeUTF(object.arguments());
    }

    @Override
    public AssistantMessage.ToolCall read(ObjectInput in) throws IOException, ClassNotFoundException {
        return new AssistantMessage.ToolCall(in.readUTF(), in.readUTF(), in.readUTF(), in.readUTF());
    }
}
